home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / scripts / title-header.scm.z / title-header.scm
Encoding:
GIMP Script-Fu Script  |  1999-07-21  |  5.0 KB  |  182 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Bump-mapped title script --- create a bump-mapped title image for web pages
  4. ; Copyright (C) 1997 Federico Mena Quintero
  5. ; federico@nuclecu.unam.mx
  6. ; This program is free software; you can redistribute it and/or modify
  7. ; it under the terms of the GNU General Public License as published by
  8. ; the Free Software Foundation; either version 2 of the License, or
  9. ; (at your option) any later version.
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ; GNU General Public License for more details.
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19. (define (script-fu-title-header text
  20.                 size
  21.                 foundry
  22.                 family
  23.                 weight
  24.                 slant
  25.                 set-width
  26.                 spacing)
  27.   (let* (; Parameters
  28.      
  29.      (padding 8)
  30.      (fade-width 64)
  31.      
  32.      ; Save foreground and background colors
  33.  
  34.      (old-fg-color (car (gimp-palette-get-foreground)))
  35.      (old-bg-color (car (gimp-palette-get-background)))
  36.      
  37.      ; Image 
  38.  
  39.      (img (car (gimp-image-new 256 256 RGB)))
  40.  
  41.      ; Text layer
  42.      
  43.      (text-layer (car (gimp-text
  44.                img
  45.                -1
  46.                0
  47.                0
  48.                text
  49.                padding
  50.                TRUE
  51.                size
  52.                PIXELS
  53.                foundry
  54.                family
  55.                weight
  56.                slant
  57.                set-width
  58.                spacing)))
  59.      (text-width (car (gimp-drawable-width text-layer)))
  60.      (text-height (car (gimp-drawable-height text-layer)))
  61.  
  62.      ; Sizes
  63.  
  64.      (text-layers-offset (/ text-height 2))
  65.  
  66.      (img-width (+ text-layers-offset text-width fade-width))
  67.      (img-height text-height)
  68.  
  69.      ; Additional layers
  70.      
  71.      (bg-layer (car (gimp-layer-new img img-width img-height RGBA_IMAGE "bg-layer" 100 NORMAL)))
  72.      (bumpmap-layer (car (gimp-layer-new img
  73.                          text-width
  74.                          text-height
  75.                          RGBA_IMAGE
  76.                          "bumpmap-layer"
  77.                          100
  78.                          NORMAL)))
  79.      (fore-layer (car (gimp-layer-new img text-width text-height RGBA_IMAGE "fore-layer" 100 NORMAL))))
  80.     
  81.     ; Create image
  82.     
  83.     (gimp-image-disable-undo img)
  84.     (gimp-image-resize img img-width img-height 0 0)
  85.     
  86.     (gimp-image-add-layer img bg-layer -1)
  87.     (gimp-image-add-layer img bumpmap-layer -1)
  88.     (gimp-image-add-layer img fore-layer -1)
  89. ;    (gimp-image-add-layer img text-layer -1)
  90.     (gimp-image-raise-layer img text-layer)
  91.     (gimp-image-raise-layer img text-layer)
  92.     (gimp-image-raise-layer img text-layer)
  93.     (gimp-layer-set-offsets bg-layer 0 0)
  94.     (gimp-layer-set-offsets text-layer text-layers-offset 0)
  95.     (gimp-layer-set-offsets bumpmap-layer text-layers-offset 0)
  96.     (gimp-layer-set-offsets fore-layer text-layers-offset 0)
  97.  
  98.     ; Create bumpmap layer
  99.  
  100.     (gimp-palette-set-background '(0 0 0))
  101.     (gimp-edit-fill img bumpmap-layer)
  102.     (gimp-selection-layer-alpha img text-layer)
  103.     (gimp-palette-set-background '(255 255 255))
  104.     (gimp-edit-fill img bumpmap-layer)
  105.     (gimp-selection-none img)
  106.     (plug-in-gauss-rle 1 img bumpmap-layer 4.0 TRUE TRUE)
  107.  
  108.     ; Fore layer, bumpmap
  109.  
  110.     (gimp-palette-set-background '(255 255 255))
  111.     (gimp-edit-fill img fore-layer)
  112.     (plug-in-bump-map 1 img fore-layer bumpmap-layer 135.0 45.0 4 0 0 0 0 FALSE FALSE 0)
  113.  
  114.     ; Text layer
  115.  
  116.     (gimp-layer-set-visible text-layer TRUE)
  117.     (gimp-layer-set-preserve-trans text-layer TRUE)
  118.     (gimp-blend img text-layer CUSTOM NORMAL LINEAR 100 0 REPEAT-NONE FALSE 0.2 3
  119.         padding
  120.         padding
  121.         (- text-width padding 1)
  122.         (- text-height padding 1))
  123.  
  124.     ; Semicircle at the left
  125.  
  126.     (gimp-palette-set-background '(0 0 0))
  127.     (gimp-edit-fill img bg-layer)
  128.     
  129.     (gimp-ellipse-select img 0 0 text-height text-height REPLACE TRUE FALSE 0)
  130.     (gimp-palette-set-background (car (gimp-color-picker img -1 text-layers-offset 0 TRUE FALSE)))
  131.     (gimp-edit-fill img bg-layer)
  132.  
  133.     ; Fade-out gradient at the right
  134.  
  135.     (gimp-rect-select img (- img-width fade-width) 0 fade-width text-height REPLACE FALSE 0)
  136.     (gimp-palette-set-foreground (car (gimp-palette-get-background)))
  137.     (gimp-palette-set-background '(0 0 0))
  138.     (gimp-blend img
  139.         bg-layer
  140.         FG-BG-RGB
  141.         NORMAL
  142.         LINEAR
  143.         100
  144.         0
  145.         REPEAT-NONE
  146.         FALSE
  147.         0.2
  148.         3
  149.         (- img-width fade-width)
  150.         0
  151.         (- img-width 1)
  152.         0)
  153.     (gimp-selection-none img)
  154.  
  155.     ; Done
  156.     
  157. ;    (gimp-image-flatten img)
  158.     (gimp-palette-set-foreground old-fg-color)
  159.     (gimp-palette-set-background old-bg-color)
  160.     (gimp-image-enable-undo img)
  161.     (gimp-display-new img)))
  162.  
  163. (script-fu-register "script-fu-title-header"
  164.             "<Toolbox>/Xtns/Script-Fu/Logos/Web title header"
  165.             "Web title header"
  166.             "Federico Mena Quintero"
  167.             "Federico Mena Quintero"
  168.             "June 1997"
  169.             ""
  170.             SF-VALUE "Text" "\"Hello world!\""
  171.             SF-VALUE "Text size" "32"
  172.             SF-VALUE "Foundry" "\"adobe\""
  173.             SF-VALUE "Family" "\"helvetica\""
  174.             SF-VALUE "Weight" "\"bold\""
  175.             SF-VALUE "Slant" "\"r\""
  176.             SF-VALUE "Set width" "\"normal\""
  177.             SF-VALUE "Spacing" "\"p\"")
  178.